import request from '@/utils/request'

// 查询设备组列表
export function listGroup(query) {
  return request({
    url: '/emqx/group/list',
    method: 'get',
    params: query
  })
}

// 查询设备组详细
export function getGroup(groupId) {
  return request({
    url: '/emqx/group/' + groupId,
    method: 'get'
  })
}

export function getMyPermissions(groupId) {
  return request({
    url: '/emqx/group/MyPermissions/' + groupId,
    method: 'get'
  })
}

// 新增设备组
export function addGroup(data) {
  return request({
    url: '/emqx/group',
    method: 'post',
    data: data
  })
}

// 修改设备组
export function updateGroup(data) {
  return request({
    url: '/emqx/group',
    method: 'put',
    data: data
  })
}

// 删除设备组
export function delGroup(groupId) {
  return request({
    url: '/emqx/group/' + groupId,
    method: 'delete'
  })
}
export function allocatedUserList(query) {
  return request({
    url: '/emqx/group/authUser/allocatedList',
    method: 'get',
    params: query
  })
}

export function unallocatedUserList(query) {
  return request({
    url: '/emqx/group/authUser/unallocatedList',
    method: 'get',
    params: query
  })
}
export function authUserSelectAll(data) {
  return request({
    url: '/emqx/group/authUser/selectAll',
    method: 'put',
    params: data
  })
}

// 取消用户授权
export function authUserCancel(data) {
  return request({
    url: '/emqx/group/authUser/cancel',
    method: 'put',
    data: data
  })
}

// 批量取消用户授权
export function authUserCancelAll(data) {
  return request({
    url: '/emqx/group/authUser/cancelAll',
    method: 'put',
    params: data
  })
}


